package io.renren.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;
import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.sys.entity.GameModuleEntity;
import io.renren.modules.sys.service.GameModuleService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Pages;
import io.renren.common.utils.ResponseModel;


/**
 *
 *
 * @author xuewenjun
 * @email xwj@kafukeji.cn
 * @date 2021-08-19 20:05:30
 */
@RestController
@RequestMapping("sys/gamemodule")
@Api(tags = "游戏模块")
public class GameModuleController {
    @Autowired
    private GameModuleService gameModuleService;

    /**
     * 列表
     */
    @PostMapping("/list")
    @ApiOperation("分页查询")
    public ResponseModel<Pages<GameModuleEntity>> list(@RequestBody GameModuleEntity gameModule){
        Pages<GameModuleEntity> page = gameModuleService.queryPage(gameModule);

        return ResponseModel.of(page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @ApiOperation("详情")
    public ResponseModel<GameModuleEntity> info(@PathVariable("id") Long id){
        GameModuleEntity gameModule = gameModuleService.getById(id);
        return ResponseModel.of(gameModule);
    }

    /**
     * 信息
     */
    @PostMapping("/column")
    @ApiOperation("过滤")
    public ResponseModel<GameModuleEntity> filterBycolumn(@RequestBody GameModuleEntity params) {
        GameModuleEntity gameModule = gameModuleService.filterByColumn(params);
        return ResponseModel.of(gameModule);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("新增")
    public ResponseModel save(@RequestBody GameModuleEntity gameModule){
        gameModuleService.save(gameModule);
        return ResponseModel.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation("修改")
    public ResponseModel update(@RequestBody GameModuleEntity gameModule) {
        gameModuleService.updateById(gameModule);

        return ResponseModel.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @ApiOperation("删除或批量删除")
    public ResponseModel delete(@RequestBody Long[] ids){
        gameModuleService.removeByIds(Arrays.asList(ids));
        return ResponseModel.ok();
    }
}
